
import React from 'react';
import { Route,Redirect,Switch } from 'react-router-dom'
import shopRouteList from './containers/shop/routes'
import loginRouteList from './containers/login/routes'
import GoodsRoutesList from './containers/goods/routes'
import AddressRoutesList from './containers/address/routes'
import OrderRoutesList from './containers/order/routes'
import AccountRoutesList from './containers/account/routes'
import Cart from './containers/cart'

import Test from './containers/test'

// 所有路由集合
let routes = [
  {
    path:'/test/test',
    component: Test
  },
  {
    path:'/cart',
    component: Cart
  },
  ...GoodsRoutesList,
  ...shopRouteList,
  ...loginRouteList,
  ...AddressRoutesList,
  ...OrderRoutesList,
  ...AccountRoutesList
  
]

export default(
  <div>
    
    <Switch>
    {
      routes.map((item,i)=>{
        return(
          <Route
            key={i}
            exact={true}
            path={item.path}
            render={({match,location})=>{
              return <item.component {...match} location={location} />
            }}
          />
        )
      })
    }
    <Redirect from="*" exact to="/home" />
    </Switch>
  </div>
)



















